<?php 

session_start();
if(!isset($_SESSION['session_key']))
    header('Location: /msc-admin/login.php');

$user = $_SESSION['session_key'];
global $db;
global $user_details;

$query = 'SELECT * FROM USERS WHERE `ID`='.$user;
$result = $db->query($query); 
$isUser = $result->num_rows;
if($isUser){
    $user = $result->fetch_assoc();
    if($user['Level'] != 1){
        header('Location: /msc-admin/login.php');
    }
    $user_details['name'] = $user['FirstName'];
    $user_details['lastname'] = $user['LastName'];
    $user_details['email'] = $user['Email'];
    $user_details['phone'] = $user['Phone'];
    
}else{
     header('Location: /msc-admin/login.php');
}

?>